import 'package:fall_data_base/fall_data_base.dart';
import 'package:froom/froom.dart';
import '../entities/user.dart';

/// Bill DAO实现 - 用于测试
@Dao()
abstract class UserDao extends BaseDao<User> {
  UserDao(super.database, super.changeListener, super.tableName,
      super.primaryKeys, super.toMap, super.toEntity, super.field2Col);
  @Query('SELECT * FROM user WHERE id = :id')
  Future<User?> findUserById(int id);

  @Query('SELECT * FROM user')
  Future<List<User>> findAllUsers();

  @Query('SELECT * FROM user')
  Stream<List<User>> findAllUsersAsStream();

  @Query('SELECT DISTINCT COUNT(name) FROM user')
  Stream<int?> findUniqueNameCountAsStream();

  @Query('SELECT * FROM user WHERE name = :name')
  Stream<List<User>> findAllTasksByNameAsStream(String name);

  @Query('UPDATE OR ABORT User SET name = :name WHERE id = :id')
  Future<int?> updateTypeById(String name, int id);
}
